package com.xianyun.site.iblog.user.executor.command;

import com.alibaba.cola.dto.Response;
import com.xianyun.site.iblog.domain.user.gateway.SystemUserGateway;
import com.xianyun.site.iblog.domain.user.model.SystemUser;
import com.xianyun.site.iblog.dto.user.SystemUserAddCmd;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 注册用户
 * @author mac_zyj
 */
@Slf4j
@Component
public class SystemUserAddCmdExo {
    @Autowired
    private SystemUserGateway  systemUserGateway;

    public Response execute(SystemUserAddCmd cmd){
        SystemUser userSave =new SystemUser();
        BeanUtils.copyProperties(cmd,userSave);
        systemUserGateway.registerUser(userSave);
        return Response.buildSuccess();
    }
}
